<template>
  <div class="xxtx-box">
    <LabelRow class="LabelRow" size='mini' v-on:onMore="onMore" v-bind:label="label"><img src="../../assets/incidentCenter/more.png" alt></LabelRow>
    <ul class="cell-ul">
      <li @click="openDialog('ProcessingDialog',{item,source:'xxzx'})" v-for="(item,index) in dataList" :key="index">
        <div class="parent-img">
          <img :src="item.eventSourceCode==1?fenjian:app" alt>
        </div>
        <div class="item-right flex flex1">
          <div class="item-right-top flex">
            <h4>{{item.eventName}}</h4>
            <!-- <img :src="item.eventSourceCode==1?fenjian:app" alt> -->
          </div>
          <div class="item-right-buottom flex">
            <el-tag size="mini">{{item.eventStatusName}}</el-tag>
            <div>{{item.classBigName}}</div>
            <div>{{getTimeStr(item.createTime)||'-'}}</div>
          </div>
        </div>
      </li>
      <div v-if="!dataList.length" class="no-data">
        <img src="../../assets/no-data.png" alt>
      </div>
    </ul>
  </div>
</template>
<script>
import LabelRow from "../common/labelRow.vue";
import { eventInfoCenterQueryMessagePage } from "../../config/api.js";
import Pubsub from "../../utils/pubsub";
import { getTimeStr } from "../../utils";
const fenjian= require('../../assets/incidentCenter/xx_icon.png');
const app= require('../../assets/incidentCenter/status_icon.png');
//WORKBENCH_MESSAGE_CENTER
export default {
  components: {
    LabelRow
  },
  data() {
    return {
      fenjian,
      app,
      label: {
        url: require("../../assets/pigeonholes/message_icon.png"),
        label: "消息中心"
      },
      dataList: [],
      getTimeStr
    };
  },
  mounted(){
    //WORKBENCH_MESSAGE_CENTER消息中心ws
    this.pubsub_token = Pubsub.subscribe("WORKBENCH_MESSAGE_CENTER", (type, values) => {
      this.getList();
    });
    this.getList();
  },
  methods: {
    onMore() {
      console.log("onMore");
    },
    openDialog(type, values) {
      if(type=='ProcessingDialog'){
        switch (values.item.eventStatusCode){
          case '1':
            values.btnType=['sl'];
            break;
          case '2':
            if(values.item.eventSourceCode==2){
              values.btnType=['pf','ja'];
            }else{
              values.btnType=['sb','pf','ja'];
            }
            break;
          case '3':
            values.btnType=[];
            break;
          default:
            values.btnType=['db','ja'];
        }
      }
      	Pubsub.publish(type, values);
    },
    getList() {
      eventInfoCenterQueryMessagePage({ pageNum: 1, pageSize: 99 }).then((res = {}) => {
          this.dataList = res.rows||[];
        }
      );
    }
  },
  destroyed() {
    this.pubsub_token && Pubsub.unsubscribe(this.pubsub_token);
  }
};
</script>

<style lang="scss" scoped>
// @import "../../css/unifyAcceptWorkbench.scss";
.xxtx-box {
  margin-top: 20px;
  margin-right: 20px;
  background-color: #fff;
  border-bottom: 1px solid #eee;
  .LabelRow{
    >img{
      padding: 5px;
    }
  }
}
.cell-ul {
  min-height: 278px;
  height: calc(100vh - 533px);
  overflow-y: auto;
  li {
    display: flex;
    justify-content: space-between;
    padding: 15px 15px 15px 20px;
    border-bottom: 1px solid #eee;
    box-sizing: border-box;
    cursor: pointer;
    .parent-img {
      margin-right: 20px;
      img {
        width: 60px;
        height: 60px;
      }
    }
    .item-right {
      flex-direction: column;
      justify-content: space-between;
      padding: 4px 0;
    }
    .item-right-top {
      justify-content: space-between;
      >img{
        width: 16px;
      }
    }
    .item-right-buottom {
      align-items: center;
      >*{
        margin-right: 10px;
        &:last-child{
          margin-right: 0;
        }
      }
      .el-tag{
        background-color: #002c65;
        padding: 0 8px;
        color: #fff;
      }
      font-size: 12px;
      color: #999;
    }
  }
}
</style>
